<?php
	$title_for_layout = $this->Html->clean($post['Post']['title']);
	$this->set(compact('title_for_layout')); 
?>
<div id="post-view">
<div class="post">
	<h1><?php echo $title_for_layout; ?></h1>
	<div class="meta"><?php echo $this->element('meta', array('post' => $post)); ?></div>
	<div class="body"><?php echo $this->Lil->autop($post['Post']['body']); ?></div>
</div>
<div class="commentlist" id="CommentList">
	<h1><?php __d('lil_blogs', 'Comments'); ?></h1><a name="comments"></a>
<?php 
	if (empty($post['Comment'])) {
		if ($post['Post']['allow_comments']) {
?>
	<div id="NoComments"><?php __d('lil_blogs', 'No comments yet. Please do add yours.'); ?></div>
<?php
		}
	} else {
		$i = 1;
		foreach($post['Comment'] as $comment) {
?>
		<div class="comment" id="c<?php echo $comment['id']; ?>">
			<div class="meta">
				<span class="commentnumber"><a href="#c<?php echo $comment['id']; ?>"><?php echo $i++; ?></a></span>
				<span class="poster"><?php echo (strlen($comment['url'])>0) ? $this->Html->link($comment['author'], $comment['url']) : $comment['author']; ?></span>
				<?php __d('lil_blogs', 'said'); ?> <?php echo $this->Time->timeAgoInWords($comment['created']); ?>:
			</div>
			<div class="message"><?php echo $this->Lil->autop($comment['body']); ?></div>
		</div>
<?php
		}
	}
?>
</div>

<?php if ($post['Post']['allow_comments']) { ?>
	<div class="form" id="CommentForm">
		<a name="addcomment"></a>
		<h1 id="PostComment"><?php __d('lil_blogs', 'Leave a Comment'); ?></h1>
		<?php
			echo $this->Form->create('Comment', array('url' => Router::url(null, true) . '#addcomment'));
			echo $this->Form->hidden('post_id', array('value' => $post['Post']['id']));
			echo $this->Form->input('author',   array('label' => __d('lil_blogs', 'Author', true) . ':', 'error' => __d('lil_blogs', 'Author is required.', true)));
			echo $this->Form->input('email',    array('label' => __d('lil_blogs', 'Email', true) . ':', 'error' => __d('lil_blogs', 'Email in proper form is required.', true)));
			echo $this->Form->input('url',      array('label' => __d('lil_blogs', 'Url', true) . ':'));
			echo $this->Form->input('body',     array('label' => __d('lil_blogs', 'Body', true) . ':', 'error' => __d('lil_blogs', 'Body is required.', true)));
			echo $this->Form->submit(__d('lil_blogs', 'Add my comment', true));
			echo $this->Form->end();
		?>
		<div id="FormNote"><?php __d('lil_blogs', 'Please be respectful; your comment my be edited or marked as spam, if necessary.'); ?></div>
	</div>
<?php } else { ?>
	<div id="CommentsClosed"><?php __d('lil_blogs', 'Sorry, comments are closed for this post. If you have any further questions or comments, feel free to contact us.');?></div>
<?php } ?>
</div>